<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="./easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/color.css">
    <script type="text/javascript" src="./easyui/jquery.min.js"></script>
    <script type="text/javascript" src="./easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
    <div style="height: 270px;width: 500px;left: 50%;top: 20%;position:absolute;margin-left: -250px;">
        <div class="easyui-panel" title="登录" style="padding:20px;" >
            <form id="ff" method="post">
                <div style="margin-bottom:20px">
                    <input class="easyui-textbox" id="username" name="username"  style="width:100%" data-options="label:'用户名:'">
                </div>
                <div style="margin-bottom:20px">
                    <input class="easyui-passwordbox" id="password" name="password"   prompt="Password" style="width:100%" iconWidth="28" data-options="label:'密码:'">
                </div>


            </form>
            <div style="text-align:center;padding:5px 0">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()" style="width:80px">登录</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="register()" style="width:80px">注册</a>
            </div>
        </div>

    </div>

    <script>
      function submitForm(){
        var username = $('#username').val();
        var password = $('#password').val();
        if(!username||!password){
            $.messager.alert("提示","用户名密码不能为空");
            return ;
        }
        $.cpost('user/login.do',{'username':username,'password':password},function(data){
          if(!data.result){
            //$.messager.alert('提示','用户名/密码错误');
            return;
          }
            $.saveLogin(data.data);
          window.location.href="report.html"
        });
      }
      function register(){
        window.location.href="user.html"
      }
    $(function(){
        $(document).keyup(function(event){
            if(event.keyCode ==13){
                submitForm();
            }
        });
    });



    </script>
</body>
</html>
